//
//  DZKeTangTableCell.m
//  dzyc
//
//  Created by 吴斌 on 2024/6/11.
//

#import "DZKeTangTableCell.h"
static NSString * KeTangTableCellId = @"KeTangTableCellId";
@interface DZKeTangTableCell()
@property (nonatomic, strong)UIImageView * keTangHeadImgView;
@property (nonatomic, strong)UILabel * keTangHeadLab;
@property (nonatomic, strong)UILabel * keTangContentLab;
@property (nonatomic,strong) UILabel *keTangTimeLab;
@end
@implementation DZKeTangTableCell
+ (instancetype)showKeTangTableCell:(UITableView *)tableView{
    DZKeTangTableCell * keTangTableCell = [tableView dequeueReusableCellWithIdentifier:KeTangTableCellId];
    if (!keTangTableCell) {
        keTangTableCell = [[DZKeTangTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:KeTangTableCellId];
    }
    keTangTableCell.backgroundColor = [UIColor clearColor];
    keTangTableCell.selectionStyle = UITableViewCellSelectionStyleNone;
    keTangTableCell.accessoryType = UITableViewCellAccessoryNone;
    return keTangTableCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self makeSubView];
    }
    return self;
}
- (void)makeSubView{
    self.keTangHeadImgView = [[UIImageView alloc] init];
    self.keTangHeadImgView.userInteractionEnabled = YES;
    [self.contentView addSubview:self.keTangHeadImgView];
    [self.keTangHeadImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DZRatio(24)));
        make.width.equalTo(@(DZRatio(242)));
        make.height.equalTo(@(DZRatio(176)));
        make.top.equalTo(@(DZRatio(0)));
    }];
    self.keTangHeadLab = [[UILabel alloc] init];
    self.keTangHeadLab.textColor = DZHex(@"#333333");
    self.keTangHeadLab.numberOfLines = 2;
    self.keTangHeadLab.font = [UIFont systemFontOfSize:DZRatio(30) weight:UIFontWeightBold];
    [self.contentView addSubview:self.keTangHeadLab];
    [self.keTangHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.keTangHeadImgView.mas_right).offset(DZRatio(29));
        make.right.equalTo(@(-DZRatio(37)));
        make.top.equalTo(@(DZRatio(0)));
    }];
    self.keTangContentLab = [[UILabel alloc] init];
    self.keTangContentLab.textColor = DZHex(@"#666666");
    self.keTangContentLab.numberOfLines = 0;
    self.keTangContentLab.font = [UIFont systemFontOfSize:DZRatio(26) weight:UIFontWeightRegular];
    [self.contentView addSubview:self.keTangContentLab];
    [self.keTangContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.keTangHeadLab);
        make.right.equalTo(@(-DZRatio(37)));
        make.top.equalTo(self.keTangHeadLab.mas_bottom).offset(DZRatio(14));
        make.height.equalTo(@(DZRatio(38)));
    }];
    UIImageView* keTangTimeImgView = [[UIImageView alloc] init];
    keTangTimeImgView.userInteractionEnabled = YES;
    keTangTimeImgView.image = DZImageNamed(@"dz_keTangTime");
    keTangTimeImgView.contentMode = UIViewContentModeScaleToFill;
    [self.contentView addSubview:keTangTimeImgView];
    [keTangTimeImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.keTangHeadLab);
        make.top.equalTo(self.keTangContentLab.mas_bottom).offset(DZRatio(16));
        make.width.equalTo(@(DZRatio(26)));
        make.height.equalTo(@(DZRatio(26)));
    }];
    self.keTangTimeLab = [[UILabel alloc] init];
    self.keTangTimeLab.textColor = DZHex(@"#999999");
    self.keTangTimeLab.font = [UIFont systemFontOfSize:DZRatio(26) weight:UIFontWeightRegular];
    [self.contentView addSubview:self.keTangTimeLab];
    [self.keTangTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(keTangTimeImgView.mas_right).offset(DZRatio(4));
        make.height.equalTo(@(DZRatio(34)));
        make.centerY.equalTo(keTangTimeImgView);
    }];
}
- (void)setKeTangKey:(NSString *)keTangKey{
    _keTangKey = keTangKey;
    _keTangKey = [_keTangKey stringByReplacingOccurrencesOfString:@"_" withString:@""];
    NSString *keTang = [NSString stringWithFormat:@"%@_img",_keTangKey];
    self.keTangHeadImgView.image = DZImageNamed(keTang);
}
-(void)setKeTangDic:(NSDictionary *)keTangDic{
    _keTangDic = keTangDic;
    if(_keTangDic){
        self.keTangHeadLab.text = [_keTangDic objectForKey:@"title"];
        self.keTangContentLab.text = [_keTangDic objectForKey:@"subTitle"];
        self.keTangTimeLab.text = [_keTangDic objectForKey:@"time"];
    }
}
@end
